package com.etc.service.impl;

import com.etc.dao.GoodsDao;
import com.etc.dao.impl.GoodsDaoImpl;
import com.etc.entity.Goods;
import com.etc.service.GoodsManageService;
import com.etc.tools.PageData;

/**

* <p>Title: GoodsManageServiceImpl</p>

* <p>Description: </p>

* @author knowno

* @date 2021年1月11日

*/
public class GoodsManageServiceImpl implements GoodsManageService{
	GoodsDao gd=new GoodsDaoImpl();
	/**
	 * 增加商品
	 */
	@Override
	public boolean addGoods(Goods goods) {
		if (goods==null) {
			return false;
		}
		boolean flag=gd.addGoods(goods);
		return flag;
	}
	/**
	 * 删除商品
	 */
	@Override
	public boolean delGoods(int goodsid) {
		boolean flag=gd.delGoods(goodsid);
		return flag;
	}
	/**
	 * 修改商品信息
	 */
	@Override
	public boolean upGoods(String goodsname, double goodsprice, String goodsinfo, int goodscount, String cover,
			int typeid, int shopid, int goodsstate, int goodsid) {
		boolean flag=gd.upGoods(goodsname, goodsprice, goodsinfo, goodscount, cover, typeid, shopid, goodsstate, goodsid);
		return flag;
	}
	/**
	 * 修改商品状态
	 */
	@Override
	public boolean updateGoods(int goodsid, int goodsstate) {
		boolean flag=gd.updateGoods(goodsid, goodsstate);
		return flag;
	}
	/**
	 * 查看店铺商品
	 */
	@Override
	public PageData<Goods> queryGoodsShopid(int page, int pageSize, int shopid) {
		if (page < 1) {
			page = 1;
		} else if (page > pageSize) {
			page = pageSize;
		}
		PageData<Goods> pd=gd.queryGoodsShopid(page, pageSize, shopid);
		return pd;
	}
	
	
	/** (non-Javadoc)
	
	* <p>Title: queryGoods</p>
	
	* <p>Description: </p>
	
	* @param page
	* @param pageSize
	* @param keywords
	* @return
	
	* @see com.etc.zmall.service.GoodsManageService#queryGoods(int, int, java.lang.String)
	
	*/
	@Override
	public PageData<Goods> queryGoods(int page, int pageSize, String keywords) {
		if (page < 1) {
			page = 1;
		} else if (page > pageSize) {
			page = pageSize;
		}
		PageData<Goods> pd=gd.queryGoods(page, pageSize, keywords);
		return pd;
	}
	
	
	/** (non-Javadoc)
	
	* <p>Title: queryGoodsShopLike</p>
	
	* <p>Description: </p>
	
	* @param page
	* @param pageSize
	* @param shopid
	* @param keywords
	* @return
	
	* @see com.etc.zmall.service.GoodsManageService#queryGoodsShopLike(int, int, int, java.lang.String)
	
	*/
	@Override
	public PageData<Goods> queryGoodsShopLike(int page, int pageSize, int shopid, String keywords) {
		if (page < 1) {
			page = 1;
		} else if (page > pageSize) {
			page = pageSize;
		}
		PageData<Goods> pd=gd.queryGoodsShopLike(page, pageSize,shopid, keywords);
		return pd;
	}

}
